package com.my.screenadapter.mService;

import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.util.Log;

import com.google.gson.Gson;

import java.util.Iterator;

/**
 * Created by zhangyingjie on 2019-10-23
 *
 * @function
 */
public class MyIntentService extends IntentService {
    private static final String TAG = "MyIntentService";
    /**
     * Creates an IntentService.  Invoked by your subclass's constructor.
     *
     */
    public MyIntentService() {
        super(TAG);
        Log.i(TAG, "MyIntentService: ");
    }

    @Override
    public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
        Log.i(TAG, "onStartCommand: ");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    protected void onHandleIntent(@Nullable Intent intent) {
        Log.i(TAG, "onHandleIntent: thread " +Thread.currentThread().getName());
        Bundle extras = intent.getExtras();
        if (extras != null && extras.keySet()!=null && extras.keySet().iterator()!=null) {
            Iterator<String> iterator = extras.keySet().iterator();
            while (iterator!=null && iterator.hasNext()){
                String next = iterator.next();
                Log.i(TAG, "onHandleIntent: bundle info key "+next+"  value "+extras.get(next));
            }
        }

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "onDestroy: ");
    }
}
